package com.ybdz.scanner.utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.ybdz.scanner.R;

/**
 * Created by Administrator on 2018/4/23/023.
 */

public class DialogUtil {

    //系列产品录入库完成对话框
    public static void luKuCompleteDialog(final Activity activity, String name_guige, String ruku_count){
        AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.UpdateDialog);
        final AlertDialog dialog = builder.create();
        if (!activity.isFinishing()){
            dialog.show();
            Window window = dialog.getWindow();
            if (window != null){
                window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
                window.setContentView(R.layout.dialog_luku_completd);
                TextView nameAndguige = (TextView) window.findViewById(R.id.nameAndguige);
                TextView rukucount = (TextView) window.findViewById(R.id.rukucount);
                Button btnCompleted = (Button) window.findViewById(R.id.btn_compelet);
                nameAndguige.setText(String.valueOf(name_guige));
                rukucount.setText(String.valueOf(ruku_count));
                btnCompleted.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.dismiss();
                        activity.finish();
                    }
                });
            }
        }
    }

//    //上下3公斤差额提示框；
//    public static void inputChaEDialog(final Activity activity, final EditText view, String guige, String weight){
//        AlertDialog.Builder builder = new AlertDialog.Builder(activity, R.style.UpdateDialog);
//        final AlertDialog dialog = builder.create();
//        if (!activity.isFinishing()){
//            dialog.show();
//            Window window = dialog.getWindow();
//            if (window != null){
//                window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
//                window.setContentView(R.layout.dialog_input_weight_confirm);
//                TextView dialog_guige = (TextView) window.findViewById(R.id.dialog_guige);
//                TextView dialog_weight = (TextView) window.findViewById(R.id.dialog_weight);
//                Button btn_compelet = (Button) window.findViewById(R.id.btn_compelet);
//                Button btn_input_again = (Button) window.findViewById(R.id.btn_input_again);
//                dialog_guige.setText(String.valueOf(guige));
//                dialog_weight.setText(String.valueOf(weight));
//                btn_compelet.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        dialog.dismiss();
//                    }
//                });
//
//                btn_input_again.setOnClickListener(new View.OnClickListener() {
//                    @Override
//                    public void onClick(View v) {
//                        dialog.dismiss();
//                        view.setFocusable(true);
//                        view.setFocusableInTouchMode(true);
//                        view.requestFocus();
//                    }
//                });
//            }
//        }
//    }
}
